package org.wesc.boot.dao.entity;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import java.io.Serializable;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.wesc.boot.common.easyexcel.GenderConverter;
import org.wesc.boot.common.easyexcel.LocalDateTimeConverter;
import org.wesc.boot.common.easyexcel.UserStatusConverter;

/**
 * <p>
 * 
 * </p>
 *
 * @author Wesley
 * @since 2019-12-09
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("sys_user")
public class User extends Model<User> {

    private static final long serialVersionUID = 1L;

    /**
     * 用户ID
     */
    @TableId(value = "USER_ID", type = IdType.AUTO)
    @ExcelIgnore
    private Long userId;

    /**
     * 用户名
     */
    @ColumnWidth(15)
    @ExcelProperty(value = {"用户名"}, index = 0)
    private String userName;

    /**
     * 密码
     */
    @ExcelIgnore
    private String password;

    /**
     * 邮箱
     */
    @ColumnWidth(30)
    @ExcelProperty(value = {"邮箱"}, index = 3)
    private String email;

    /**
     * 联系电话
     */
    @ColumnWidth(20)
    @ExcelProperty(value = {"手机号"}, index = 4)
    private String mobile;

    /**
     * 0有效 1锁定
     */
    @ColumnWidth(20)
    @ExcelProperty(value = {"账户状态"}, index = 5, converter = UserStatusConverter.class)
    private String locked;

    /**
     * 创建时间
     */
    @ColumnWidth(30)
    @ExcelProperty(value = {"创建时间"}, index = 6, converter = LocalDateTimeConverter.class)
    private LocalDateTime createTime;

    /**
     * 修改时间
     */
    @ExcelIgnore
    private LocalDateTime modifyTime;

    /**
     * 最近访问时间
     */
    @ExcelIgnore
    private LocalDateTime lastLoginTime;

    /**
     * 性别 0男 1女 2保密
     */
    @ColumnWidth(15)
    @ExcelProperty(value = {"性别"}, index = 2, converter = GenderConverter.class)
    private String gender;

    /**
     * 描述
     */
    @ExcelIgnore
    private String description;

    /**
     * 用户头像
     */
    @ExcelIgnore
    private String avatar;


    public static final String USER_ID = "USER_ID";

    public static final String USER_NAME = "USER_NAME";

    public static final String PASSWORD = "PASSWORD";

    public static final String EMAIL = "EMAIL";

    public static final String MOBILE = "MOBILE";

    public static final String LOCKED = "LOCKED";

    public static final String CREATE_TIME = "CREATE_TIME";

    public static final String MODIFY_TIME = "MODIFY_TIME";

    public static final String LAST_LOGIN_TIME = "LAST_LOGIN_TIME";

    public static final String GENDER = "GENDER";

    public static final String DESCRIPTION = "DESCRIPTION";

    public static final String AVATAR = "AVATAR";

    @Override
    protected Serializable pkVal() {
        return this.userId;
    }

}
